set more 1

/*
File:	cepr_org_empstat.do
Date:	Nov 14, 2005, CEPR ORG Version 1.0
	Jan  3, 2012, CEPR ORG Version 1.7
	Mar 12, 2015, CEPR ORG Version 2.0
	Apr  1, 2015, CEPR ORG Version 2.0.1
	March 1, 2016, CEPR ORG Version 2.1
	Oct 12, 2016, CEPR ORG Version 2.1.1
	Feb 9, 2017, CEPR ORG Version 2.2
	Apr 21, 2017, CEPR ORG Version 2.2.1
	Apr 10, 2018, CEPR ORG Version 2.3
	Mar 22, 2019, CEPR ORG Version 2.4
	Jul 24, 2019, CEPR ORG Version 2.4.1
	Feb 05, 2020, CEPR ORG Version 2.5
	
Desc:	Creates consistent employment status variables for CEPR consistent
	extract	of CPS ORG
Note:	See copyright notice at end of program.
*/

/* Determine data year */
local year=year in 1
if `year'==-17345 {local year  = 1980}
di "`year'"

/* Labor-market status */

if 1979<=`year' & `year'<=1988 {
gen byte lfstat=1 if esr==1 | esr==2
replace lfstat=2 if esr==3
replace lfstat=3 if 4<=esr & esr<=7
}
if 1989<=`year' & `year'<=1993 {
gen byte lfstat=1 if lfsr89==1 | lfsr89==2
replace lfstat=2 if 3<=lfsr89 & lfsr89<=4
replace lfstat=3 if 5<=lfsr89 & lfsr89<=7
}

lab var lfstat "Labor-force status"
#delimit ;
lab def lfstat
1 "Employed"
2 "Unemployed"
3 "NILF"
;
#delimit cr
lab val lfstat lfstat
notes lfstat: CPS: derived from a-lfsr, pemlr


/* Employed */
gen byte empl=0 if lfstat~=.
replace empl=1 if lfstat==1
lab var empl "Employed"
notes empl: CPS: derived from a-lfsr, pemlr

/* Unemployed */
gen byte unem=0 if lfstat~=.
replace unem=1 if lfstat==2
lab var unem "Unemployed"
notes unem: CPS: derived from a-lfsr, pemlr

/* Not in labor force */
gen byte nilf=0 if lfstat~=.
replace nilf=1 if lfstat==3
lab var nilf "Not in labor force"
notes nilf: CPS: derived from a-lfsr, pemlr

/* Self-employed (unincorporated) */

if 1979<=`year' & `year'<=1988 {
gen byte selfemp=0 if class~=. & class~=8 /* 8 = never worked */
replace selfemp=1 if class==6
}
if 1989<=`year' & `year'<=1993 {
gen byte selfemp=0 if classer~=. & classer~=8 /* 8 = never worked */
replace selfemp=1 if classer==6
}

lab var selfemp "Self-employed"
notes selfemp: Unincorporated self-employed only
notes selfemp: CPS: derived from a-clswkr, peio1cow

/* Incorporated self-employed */

if 1979<=`year' & `year'<=1988 {
gen byte selfinc=0 if class~=. & class~=8 /* 8 = never worked */
replace selfinc=1 if class==5
}
if 1989<=`year' & `year'<=1993 {
gen byte selfinc=0 if classer~=. & classer~=8 /* 8 = never worked */
replace selfinc=1 if classer==5
}

lab var selfinc "Incorporated self-employed"
notes selfinc: Incorporated self-employed only
notes selfinc: CPS: derived from a-clswkr, peio1cow

/* Public sector */

if 1979<=`year' & `year'<=1988 {
gen byte pubsect=0 if class~=. & class~=8 /* 8 = never worked */
replace pubsect=1 if 2<=class & class<=4 
}
if 1989<=`year' & `year'<=1993 {
gen byte pubsect=0 if classer~=. & classer~=8 /* 8 = never worked */
replace pubsect=1 if 2<=classer & classer<=4
}

lab var pubsect "Public sector"
notes pubsect: Federal, state, and local
notes pubsect: CPS: derived from a-clswkr, peio1cow

	/* Federal */

if 1979<=`year' & `year'<=1988 {
gen byte pubfed=0 if class~=. & class~=8 /* 8 = never worked */
replace pubfed=1 if class==2
}
if 1989<=`year' & `year'<=1993 {
gen byte pubfed=0 if classer~=. & classer~=8 /* 8 = never worked */
replace pubfed=1 if classer==2
}

lab var pubfed "Federal employee"
notes pubfed: CPS: derived from a-clswkr, peio1cow

	/* State */

if 1979<=`year' & `year'<=1988 {
gen byte pubst=0 if class~=. & class~=8 /* 8 = never worked */
replace pubst=1 if class==3
}
if 1989<=`year' & `year'<=1993 {
gen byte pubst=0 if classer~=. & classer~=8 /* 8 = never worked */
replace pubst=1 if classer==3
}

lab var pubst "State employee"
notes pubst: CPS: derived from a-clswkr, peio1cow

	/* Local */

if 1979<=`year' & `year'<=1988 {
gen byte publoc=0 if class~=. & class~=8 /* 8 = never worked */
replace publoc=1 if class==4
}
if 1989<=`year' & `year'<=1993 {
gen byte publoc=0 if classer~=. & classer~=8 /* 8 = never worked */
replace publoc=1 if classer==4
}

lab var publoc "Local employee"
notes publoc: CPS: derived from a-clswkr, peio1cow

/* Class of worker on 1st job */

if 1979<=`year' & `year'<=1993 {
gen byte cow1=.
}

#delimit ;
lab def cow1
1 "GOVERNMENT - FEDERAL"
2 "GOVERNMENT - STATE"
3 "GOVERNMENT - LOCAL"
4 "PRIVATE, FOR PROFIT"
5 "PRIVATE, NONPROFIT"
6 "SELF-EMPLOYED, INCORPORATED"                                 
7 "SELF-EMPLOYED, UNINCORPORATED"
8 "WITHOUT PAY"
;
#delimit cr
lab val cow1 cow1

lab var cow1 "Class of Worker, 1st job"
notes cow1: CPS: peio1cow
notes cow1: Available 1994-present


/* Class of worker on 2nd job */

if 1979<=`year' & `year'<=1993 {
gen byte cow2=.
}
#delimit ;
lab def cow2
1 "GOVERNMENT - FEDERAL"
2 "GOVERNMENT - STATE"
3 "GOVERNMENT - LOCAL"
4 "PRIVATE, FOR PROFIT"
5 "PRIVATE, NONPROFIT"
6 "SELF-EMPLOYED, INCORPORATED"                                 
7 "SELF-EMPLOYED, UNINCORPORATED"
8 "WITHOUT PAY"
;
#delimit cr
lab val cow2 cow2
lab var cow2 "Class of Worker, 2nd job"
notes cow2: CPS: peio2cow
notes cow2: Available 1994-present

/* Unemployment duration, job loser, job leaver */

if 1979<=`year' & `year'<=1993 {
gen byte unemdur=.
gen byte jobloser=.
gen byte jobleaver=.
gen byte entrant=.
}

lab var unemdur "Unemployment duration (weeks)"
notes unemdur: Available 1994- only
notes unemdur: CPS: derived from prunedur

lab var jobloser "Job loser"
notes jobloser: Available 1994- only
notes jobloser: CPS derived from pruntype
notes jobloser: Includes those whose temporary job ended

lab var jobleaver "Job leaver"
notes jobleaver: Available 1994- only
notes jobleaver: CPS derived from pruntype

lab var entrant "Entrant"
notes entrant: Available 1994- only
notes entrant: CPS derived from pruntype
notes entrant: Includes new and returning entrants

/* Union */

	/* Member */

if 1979<=`year' & `year'<=1982 {
gen byte unmem=.
}
if 1983<=`year' & `year'<=1993 {
gen byte unmem=0 if unionmme~=.
replace unmem=1 if unionmme==1
}
lab var unmem "Union member"
notes unmem: Not available before 1983
notes unmem: CPS: a-unmem, peernlab

	/* Coverage */

if 1979<=`year' & `year'<=1982 {
gen byte uncov=0
}
if 1983<=`year' & `year'<=1993 {
gen byte uncov=0 if unioncov~=.
replace uncov=1 if unioncov==1
}
lab var uncov "Union coverage"
notes uncov: Not available before 1983
notes uncov: CPS: a-uncov, peerncov

	/* Member or covered */
	
if 1979<=`year' & `year'<=1982 {
gen byte union=.
}
if 1983<=`year' & `year'<=1993 {
gen byte union=0 if unmem~=.
replace union=1 if unmem==1
replace union=1 if uncov==1
}
lab var union "Union"
notes union: Not available before 1983
notes union: Union member or covered by union contract
notes union: CPS: derived from a-unmem, peernlab, a-uncov, peerncov

/* Occupational Licensing Professional Ceritification */
gen byte cert=.
gen byte certgov=.


/* School Enrollment Variables */

	/* Enrolled in school */
	
gen byte schenrl=.

if 1979<=`year' & `year'<=1983 {
* schenrl not available
}
if 1984<=`year' & `year'<=1993 {
replace schenrl=0 if schenr==2
replace schenrl=1 if schenr==1
}

lab var schenrl "Enrolled in HS or College last week"
notes schenrl: Not available before 1984
notes schenrl: Age 16-24 only
notes schenrl: From 1984-2012, valid for ages 16-24
notes schenrl: From 2013-on, valid for ages 16-54
notes schenrl: CPS: derived from a-enrlw, peschenr

	/* High School */
	
gen byte schhs=.

if 1979<=`year' & `year'<=1983 {
* schhs not available
}
if 1984<=`year' & `year'<=1993 {
replace schhs=0 if schlvl==2
replace schhs=1 if schlvl==1
}

lab var schhs "Enrolled in HS"
notes schhs: Not available before 1984
notes schhs: Age 16-24 only
notes schhs: From 1984-2012, valid for ages 16-24
notes schhs: From 2013-on, valid for ages 16-54
notes schhs: CPS: derived from a-hscol, peschlvl

	/* College */
	
gen byte schcol=.

if 1979<=`year' & `year'<=1983 {
* schcol not available
}
if 1984<=`year' & `year'<=1993 {
replace schcol=0 if schlvl==1
replace schcol=1 if schlvl==2
}

lab var schcol "Enrolled in College"
notes schcol: Not available before 1984
notes schcol: Age 16-24 only
notes schcol: From 1984-2012, valid for ages 16-24
notes schcol: From 2013-on, valid for ages 16-54
notes schcol: CPS: derived from a-hscol, peschlvl

	/* Full-time */
	
gen byte schft=.

if 1979<=`year' & `year'<=1983 {
* schft not available
}
if 1984<=`year' & `year'<=1993 {
replace schft=0 if studftpt==2 & 16<=age & age<=24
replace schft=1 if studftpt==1 & 16<=age & age<=24
}

lab var schft "Full-time Student"

lab var schft "Full-time Student"
notes schft: Not available before 1984
notes schft: Age 16-24 only
notes schft: CPS docs say underlying CPS variable only for /*
*/ ages 16-24 from 1984-2012, but small number are for higher ages in 89-93. /*
*/ For consistency, restricted ages 16-24
notes schft: From 1984-2012, valid for ages 16-24
notes schft: From 2013-on, valid for ages 16-54
notes schft: CPS: derived from a-ftpt, peschft
notes schft: Part-time students coded as zero

	/* Part-time */
	
gen byte schpt=.

if 1979<=`year' & `year'<=1983 {
* schpt not available
}
if 1984<=`year' & `year'<=1993 {
replace schpt=0 if studftpt==1 & 16<=age & age<=24
replace schpt=1 if studftpt==2 & 16<=age & age<=24
}

lab var schpt "Part-time Student"

notes schpt: Not available before 1984
notes schpt: Age 16-24 only
notes schpt: CPS docs say underlying CPS variable only for /*
*/ ages 16-24 from 1984-2012, but small number are for higher ages in 89-93. /*
*/ For consistency, restricted ages 16-24
notes schpt: From 1984-2012, valid for ages 16-24
notes schpt: From 2013-on, valid for ages 16-54
notes schpt: CPS: derived from a-ftpt, peschft
notes schpt: Full-time students coded as zero

/* More than one job */

gen byte multjob=.

lab var multjob "Has more than one job"
notes multjob: Not available before 1994
notes multjob: Universe: lfstat==1
notes multjob: CPS: derived from pemjot

gen byte multjobn=.

lab var multjobn "Number of jobs"
notes multjobn: Number 4 corresponds to four or more
notes multjob: Not available before 1994
notes multjob: Universe: lfstat==1
notes multjob: CPS: derived from pemjot, pemjnum

/* Paid Employees Information */

gen byte pdemp1=.
gen byte pdemp2=.
gen byte nmemp1=.
gen byte nmemp2=.


lab var pdemp1 "Usually has paid employees"
notes pdemp1: CPS: derived from pepdemp1
notes pdemp1: not available before 2014

lab var pdemp2 "Usually has paid employees"
notes pdemp2: CPS: derived from pepdemp2
notes pdemp2: not available before 2014

lab var nmemp1 "Number of paid employees"
notes nmemp1: CPS: derived from ptnmemp1
notes nmemp1: not available before 2014

lab var nmemp2 "Number of paid employees"
notes nmemp2: CPS: derived from ptnmemp2
notes nmemp2: not available before 2014


/* 
Copyright 2020 CEPR and John Schmitt

This file is part of the cepr_org_master.do program. This file and all
programs referenced in it are free software. You can redistribute the
program or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
USA.
*/

